import cn.jiguang.common.resp.APIConnectionException;
import cn.jiguang.common.resp.APIRequestException;
import cn.jpush.api.JPushClient;
import cn.jpush.api.push.model.Platform;
import cn.jpush.api.push.model.PushPayload;
import cn.jpush.api.push.model.audience.Audience;
import cn.jpush.api.push.model.notification.AndroidNotification;
import cn.jpush.api.push.model.notification.Notification;

public class MyTest {
    public static void main(String[] args) {
        try {
      /*      //构建推送客户端
            JPushClient jPushClient = new JPushClient("c7e8e44b63d95ec9bc94f965", "55de5d60083f940ffdd34c32");

            //组装推送对象
            PushPayload payload = PushPayload.newBuilder()
                    .setPlatform(Platform.all()) //全平台
                    .setAudience(Audience.alias("17792648116")) //推送目标用户
                    .setNotification(Notification.newBuilder().addPlatformNotification(
                            AndroidNotification.newBuilder().setTitle("测试一家伙").setAlert("测试的申请加入企业,请及时审批").build()).build())
                    .build();

            //推送消息
            //for (int i = 0; i < 10; i++) {
                jPushClient.sendPush(payload);
            //}*/
            //构建推送客户端
            JPushClient jPushClient = new JPushClient("c7e8e44b63d95ec9bc94f965", "55de5d60083f940ffdd34c32");

            //组装推送对象
            PushPayload payload = PushPayload.newBuilder()
                    .setPlatform(Platform.all())
                    .setAudience(Audience.alias("17792648116"))
                    .setNotification(Notification.newBuilder().addPlatformNotification(
                            AndroidNotification.newBuilder().setTitle("申请加入").setAlert("我测试一下申请加入企业,请审批").build()).build())
                    .build();

            //推送消息
            jPushClient.sendPush(payload);
            System.out.println("发送成功");
        } catch (APIConnectionException e) {
            e.printStackTrace();
        } catch (APIRequestException e) {
            e.printStackTrace();
        }

    }
}
